package com.woniu.mall.controller;

import com.woniu.common.entity.Result;
import com.woniu.mall.pojo.Coupon;
import com.woniu.mall.service.CouponPlatformService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * 1. @description:
 * 2. @author: Lingger
 * 3. @time: 2023/5/22
 */

@RequestMapping("/couponPlatform")
@RestController
@Api(tags = "优惠券平台端")
public class CouponPlatformController {

    @Autowired
    private CouponPlatformService couponPlatformService;

    //新增分区优惠券
    @ApiOperation("新增分区优惠券")
    @PostMapping("/saveZone")
    public Result saveZoneCoupon(@RequestBody Coupon coupon) {

        Boolean flag = couponPlatformService.saveZoneCoupon(coupon);
        return Result.ok(flag);
    }

    //删除分区优惠券
    @ApiOperation("删除分区优惠券")
    @GetMapping("/deleteZone/{couponName}/{amount}")
    public Result deleteZone(@PathVariable("couponName") String couponName,
                             @PathVariable("amount") BigDecimal amount) {

        Long number = couponPlatformService.deleteZone(couponName, amount);
        return Result.ok(number);
    }

    //生成天天神券测试专用接口
    @ApiOperation("生成天天神券测试专用接口")
    @GetMapping("/saveTianTian")
    public Result saveTianTian() {
        Coupon coupon = couponPlatformService.saveTianTian();
        return Result.ok(coupon);
    }

    //生成红包测试专用接口
    @ApiOperation("生成红包测试专用接口")
    @GetMapping("/saveRedEnvelope")
    public Result saveRedEnvelope() {
        Coupon coupon = couponPlatformService.saveRedEnvelope();
        return Result.ok(coupon);
    }
}
